<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		请输入数字：<input type="text" onkeypress="fun()"/>
		<script type="text/javascript">
			function fun(){
				console.log(`你按下了键盘${event.key},ASCII码是${event.keyCode}`)
				if(event.keyCode<48||event.keyCode>57)
				console.error("不能输入非数字")
				event.preventDefault()
			}
		</script>
	</body>
</html>
